import redis

class RedisM:
    def __init__(self) -> None:
        self.r=redis.Redis(host='127.0.0.1',port=6379,db=1)
    # 添加
    def add_set(self,key,value):
        print(value)
        return self.r.sadd(key,value)
    # 获取集合所有元素
    def get_set(self,key):
        res=self.r.smembers(key)
        return res
    # 删除元素
    def del_set(self,key,value):
        return self.r.srem(key,*value)
    # 获取元素个数
    def num_set(self,key):
        num=self.r.scard(key)
        return num
    # 判断某元素是否存在
    def if_set(self,key,value):
        res=self.r.sismember(key,value)
        return res


redism=RedisM()        